const path = require('path')
module.exports = {
  publicPath: './',
  outputDir: 'dist',
  assetsDir: 'assets/',
  lintOnSave: false,
  runtimeCompiler: true,
  productionSourceMap: false,
  devServer: {
    open: true,
    port: 7050,
    compress: true,
    disableHostCheck: true,
    proxy: null,
    hot: true
  },
  chainWebpack: (config) => {
    config.set('externals', { AMap: 'AMap', AMapUI: 'AMapUI' })
    const svgRule = config.module.rule('svg')
    svgRule.uses.clear()
    svgRule
      .test(/\.svg$/)
      .include.add(path.resolve(__dirname, './src/icons'))
      .end()
      .use('svg-sprite-loader')
      .loader('svg-sprite-loader')
      .options({
        symbolId: 'icon-[name]'
      })
    const fileRule = config.module.rule('file')
    fileRule.uses.clear()
    fileRule
      .test(/\.svg$/)
      .exclude.add(path.resolve(__dirname, './src/icons'))
      .end()
      .use('file-loader')
      .loader('file-loader')
  }
}
